import request from '@/utils/request'

// 2.导入getToken
// import { getToken } from '../utils/token'
// 获取所有频道列表
const getAllChannelListAPI = () => request({
  method: 'get',
  url: '/v1_0/channels'
})

// 1.获取文章列表
//   多个参数,不想受顺序影响,传一个对象
const getArticleListAPI = ({
  status = null,
  channel_id = null,
  begin_pubdate = null,
  end_pubdate = null,
  page = 1,
  per_page = 10
}) => request({
  method: 'get',
  url: '/v1_0/mp/articles',
  // 3.请求头
  // headers: {
  //   Authorization: `Bearer ${getToken()}`
  // },
  // 4.查询参数?参数名=值 ->params
  params: {
    status,
    channel_id,
    begin_pubdate,
    end_pubdate,
    page,
    per_page
  }
})

// 删除文章接口
// Path： /v1_0/mp/articles/:target
// :为占位符,传参时不需要,用模板字符串拼接需要传的参数
const delArticleListAPI = ({ artId }) => request({
  method: 'DELETE',
  url: `/v1_0/mp/articles/${artId}`

})

// 5.导出
export {
  getAllChannelListAPI, getArticleListAPI, delArticleListAPI
}
